﻿<Page
    x:Class="UpdateControls.Test.App.MainPage"
    IsTabStop="false"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:UpdateControls.Test.App"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    DataContext="{Binding Main, Source={StaticResource Locator}}">
    
    <Page.Resources>
        <local:DebugConverter x:Key="DebugConverter"/>
    </Page.Resources>

    <Grid x:Name="LayoutRoot" Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition
                Width="250" />
            <ColumnDefinition
                Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="auto"/>
        </Grid.RowDefinitions>

        <Border
            Margin="3">
            <ListBox ItemsSource="{Binding People}" SelectedItem="{Binding SelectedPerson, Mode=TwoWay}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding FullName}"/>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </Border>

        <StackPanel Grid.Row="1">
            <Grid DataContext="{Binding PersonDetail, Source={StaticResource Locator}}">
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                </Grid.RowDefinitions>

                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>

                <Border Grid.Row="0" Grid.Column="0">
                    <TextBlock Text="Prefix:"/>
                </Border>
                <Border Grid.Row="0" Grid.Column="1">
                    <ComboBox ItemsSource="{Binding DataContext.Prefixes, ElementName=LayoutRoot}" SelectedItem="{Binding Prefix, Mode=TwoWay}"/>
                </Border>
                <Border Grid.Row="1" Grid.Column="0">
                    <TextBlock Text="First Name:"/>
                </Border>
                <Border Grid.Row="1" Grid.Column="1">
                    <TextBox Text="{Binding First, Mode=TwoWay}"/>
                </Border>
                <Border Grid.Row="2" Grid.Column="0">
                    <TextBlock Text="Last Name:"/>
                </Border>
                <Border Grid.Row="2" Grid.Column="1">
                    <TextBox Text="{Binding Last, Mode=TwoWay}"/>
                </Border>
                <Border Grid.Row="3" Grid.Column="0">
                    <TextBlock Text="Gender:"/>
                </Border>
                <Border Grid.Row="3" Grid.Column="1">
                    <ComboBox ItemsSource="{Binding DataContext.GenderOptions, ElementName=LayoutRoot}" SelectedItem="{Binding Gender, Mode=TwoWay, Converter={StaticResource DebugConverter}}"/>
                </Border>
                <Border Grid.Row="4" Grid.Column="0">
                    <TextBlock Text="Spouse:"/>
                </Border>
                <Border Grid.Row="4" Grid.Column="1">
                    <ComboBox ItemsSource="{Binding PotentialSpouses}" SelectedItem="{Binding Spouse, Mode=TwoWay}">
                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding FullName}"/>
                            </DataTemplate>
                        </ComboBox.ItemTemplate>
                    </ComboBox>
                </Border>
            </Grid>
        </StackPanel>

        <StackPanel Grid.Row="2" Orientation="Horizontal">
            <Border>
                <Button Command="{Binding NewPerson}">New Person</Button>
            </Border>
            <Border>
                <Button Command="{Binding DeletePerson}">Delete Person</Button>
            </Border>
        </StackPanel>
    </Grid>
</Page>
